<?php

namespace app\index\validate;

use think\Validate;

class LoginValidate extends Validate
{
    protected $rule = [
        'phone' => 'require|mobile',
        'password'  =>  'require|length:32',
        'code'  =>  'require|length:' . CAPTCHA_LENGTH,
        'key'   =>  'require',
        'scene' =>  'in:register,login'
    ];

    protected $message = [
        'phone.require' =>  [
            'code'  =>  INVALID_PARAM,
            'msg' => '请输入手机号'
        ],
        'phone.mobile'  =>  [
            'code'  =>  INVALID_PARAM,
            'msg'   =>  '手机号格式错误'
        ]
    ];

    protected $scene = [
        'login' =>  [
            'phone', 'password', 'code', 'key'
        ]
    ];
}